diff -r 06549f98901b ipc/chromium/src/base/debug_util_posix.cc
--- a/ipc/chromium/src/base/debug_util_posix.cc	Fri Aug 02 14:36:52 2013 +0000
+++ b/ipc/chromium/src/base/debug_util_posix.cc	Fri Aug 02 14:42:20 2013 +0000
@@ -5,7 +5,7 @@
 #include "build/build_config.h"
 #include "base/debug_util.h"
 
-#define MOZ_HAVE_EXECINFO_H (defined(OS_LINUX) && !defined(ANDROID))
+#define MOZ_HAVE_EXECINFO_H (defined(OS_LINUX) && defined(__GLIBC__))
 
 #include <errno.h>
 #include <fcntl.h>
diff -r 06549f98901b ipc/chromium/src/base/file_util.h
--- a/ipc/chromium/src/base/file_util.h	Fri Aug 02 14:36:52 2013 +0000
+++ b/ipc/chromium/src/base/file_util.h	Fri Aug 02 14:42:20 2013 +0000
@@ -16,7 +16,11 @@
 #include <sys/stat.h>
 #elif defined(OS_POSIX) 
 #include <sys/types.h>
+#ifndef __GLIBC__
+#define NO_FTS
+#else
 #include <fts.h>
+#endif
 #include <sys/stat.h>
 #endif
 
diff -r 06549f98901b ipc/chromium/src/base/file_util_posix.cc
--- a/ipc/chromium/src/base/file_util_posix.cc	Fri Aug 02 14:36:52 2013 +0000
+++ b/ipc/chromium/src/base/file_util_posix.cc	Fri Aug 02 14:42:20 2013 +0000
@@ -8,13 +8,16 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <fnmatch.h>
-#ifndef ANDROID
+#ifndef __GLIBC__
+#define NO_FTS
+#endif
+#ifndef NO_FTS
 #include <fts.h>
 #endif
 #include <libgen.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/errno.h>
+#include <errno.h>
 #include <sys/mman.h>
 #define _DARWIN_USE_64_BIT_INODE // Use 64-bit inode data structures
 #include <sys/stat.h>
@@ -121,7 +124,7 @@
   if (!recursive)
     return (rmdir(path_str) == 0);
 
-#ifdef ANDROID
+#ifdef NO_FTS
   // XXX Need ftsless impl for bionic
   return false;
 #else
@@ -194,7 +197,7 @@
     return false;
   }
 
-#ifdef ANDROID
+#ifdef NO_FTS
   // XXX Need ftsless impl for bionic
   return false;
 #else
diff -r 06549f98901b ipc/chromium/src/base/time_posix.cc
--- a/ipc/chromium/src/base/time_posix.cc	Fri Aug 02 14:36:52 2013 +0000
+++ b/ipc/chromium/src/base/time_posix.cc	Fri Aug 02 14:42:20 2013 +0000
@@ -65,8 +65,10 @@
   timestruct.tm_wday   = exploded.day_of_week;  // mktime/timegm ignore this
   timestruct.tm_yday   = 0;     // mktime/timegm ignore this
   timestruct.tm_isdst  = -1;    // attempt to figure it out
+#ifdef __GLIBC__
   timestruct.tm_gmtoff = 0;     // not a POSIX field, so mktime/timegm ignore
   timestruct.tm_zone   = NULL;  // not a POSIX field, so mktime/timegm ignore
+#endif
 
   time_t seconds;
 #ifdef ANDROID
diff -r 06549f98901b media/libcubeb/src/cubeb_alsa.c
--- a/media/libcubeb/src/cubeb_alsa.c	Fri Aug 02 14:36:52 2013 +0000
+++ b/media/libcubeb/src/cubeb_alsa.c	Fri Aug 02 14:42:20 2013 +0000
@@ -6,6 +6,7 @@
  */
 #undef NDEBUG
 #define _BSD_SOURCE
+#define _POSIX_C_SOURCE 200112L
 #define _XOPEN_SOURCE 500
 #include <pthread.h>
 #include <sys/time.h>
diff -r 06549f98901b media/webrtc/trunk/testing/gtest/src/gtest.cc
--- a/media/webrtc/trunk/testing/gtest/src/gtest.cc	Fri Aug 02 14:36:52 2013 +0000
+++ b/media/webrtc/trunk/testing/gtest/src/gtest.cc	Fri Aug 02 14:42:20 2013 +0000
@@ -48,6 +48,8 @@
 #include <sstream>
 #include <vector>
 
+#include <sys/socket.h>
+
 #if GTEST_OS_LINUX
 
 // TODO(kenton@google.com): Use autoconf to detect availability of
diff -r 06549f98901b netwerk/sctp/src/netinet/sctp_bsd_addr.c
--- a/netwerk/sctp/src/netinet/sctp_bsd_addr.c	Fri Aug 02 14:36:52 2013 +0000
+++ b/netwerk/sctp/src/netinet/sctp_bsd_addr.c	Fri Aug 02 14:42:20 2013 +0000
@@ -49,11 +49,9 @@
 #include <netinet/sctp_sysctl.h>
 #include <netinet/sctp_indata.h>
 #if !defined(__Userspace_os_Windows)
+#include <unistd.h>
 #if defined(ANDROID)
-#include <unistd.h>
 #include <ifaddrs-android-ext.h>
-#else
-#include <sys/unistd.h>
 #endif
 #endif
 
diff -r 06549f98901b netwerk/sctp/src/netinet/sctp_os_userspace.h
--- a/netwerk/sctp/src/netinet/sctp_os_userspace.h	Fri Aug 02 14:36:52 2013 +0000
+++ b/netwerk/sctp/src/netinet/sctp_os_userspace.h	Fri Aug 02 14:42:20 2013 +0000
@@ -408,7 +407,7 @@
 /* #include <sys/param.h>  in FreeBSD defines MSIZE */
 /* #include <sys/ktr.h> */
 /* #include <sys/systm.h> */
-#if defined(__Userspace_os_Windows)
+#if defined(__Userspace_os_Windows) || 1
 #include <user_queue.h>
 #else
 #include <sys/queue.h>
diff -r 06549f98901b netwerk/sctp/src/netinet/sctp_pcb.c
--- a/netwerk/sctp/src/netinet/sctp_pcb.c	Fri Aug 02 14:36:52 2013 +0000
+++ b/netwerk/sctp/src/netinet/sctp_pcb.c	Fri Aug 02 14:42:20 2013 +0000
@@ -30,6 +30,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define _BSD_SOURCE /* for IPPORT_RESERVED */
+
 #ifdef __FreeBSD__
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 246687 2013-02-11 21:02:49Z tuexen $");
@@ -69,11 +71,10 @@
 #endif
 #if defined(__Userspace__)
 #if !defined(__Userspace_os_Windows)
+#include <netdb.h>
+#include <unistd.h>
 #if defined(ANDROID)
-#include <unistd.h>
 #include <ifaddrs-android-ext.h>
-#else
-#include <sys/unistd.h>
 #endif
 #endif
 #include <user_socketvar.h>
diff -r 06549f98901b netwerk/sctp/src/user_queue.h
--- a/netwerk/sctp/src/user_queue.h	Fri Aug 02 14:36:52 2013 +0000
+++ b/netwerk/sctp/src/user_queue.h	Fri Aug 02 14:42:20 2013 +0000
@@ -31,9 +31,6 @@
 #ifndef _USER_QUEUE_H_
 #define	_USER_QUEUE_H_
 
-#if !defined (__Userspace_os_Windows)
-#include <sys/cdefs.h>
-#endif
 /*
  * This file defines four types of data structures: singly-linked lists,
  * singly-linked tail queues, lists and tail queues.
diff -r 06549f98901b toolkit/crashreporter/google-breakpad/src/common/linux/dump_symbols.cc
--- a/toolkit/crashreporter/google-breakpad/src/common/linux/dump_symbols.cc	Fri Aug 02 14:36:52 2013 +0000
+++ b/toolkit/crashreporter/google-breakpad/src/common/linux/dump_symbols.cc	Fri Aug 02 14:42:20 2013 +0000
@@ -46,6 +46,9 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+// [Gregor] POSIX specifies dirname/basename as in libgen.h
+#include <libgen.h>
+
 #include <iostream>
 #include <set>
 #include <string>
diff -r 06549f98901b toolkit/crashreporter/google-breakpad/src/common/stabs_reader.cc
--- a/toolkit/crashreporter/google-breakpad/src/common/stabs_reader.cc	Fri Aug 02 14:36:52 2013 +0000
+++ b/toolkit/crashreporter/google-breakpad/src/common/stabs_reader.cc	Fri Aug 02 14:42:20 2013 +0000
@@ -41,6 +41,10 @@
 
 #include "common/using_std_string.h"
 
+#ifndef N_UNDF
+#define N_UNDF 0
+#endif
+
 using std::vector;
 
 namespace google_breakpad {
diff -r 06549f98901b toolkit/crashreporter/google-breakpad/src/common/stabs_reader.h
--- a/toolkit/crashreporter/google-breakpad/src/common/stabs_reader.h	Fri Aug 02 14:36:52 2013 +0000
+++ b/toolkit/crashreporter/google-breakpad/src/common/stabs_reader.h	Fri Aug 02 14:42:20 2013 +0000
@@ -53,7 +53,7 @@
 #include <config.h>
 #endif
 
-#ifdef HAVE_A_OUT_H
+#if 0
 #include <a.out.h>
 #endif
 #ifdef HAVE_MACH_O_NLIST_H
diff -r 06549f98901b toolkit/crashreporter/google-breakpad/src/stab.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolkit/crashreporter/google-breakpad/src/stab.h	Fri Aug 02 14:42:20 2013 +0000
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)stab.h	8.1 (Berkeley) 6/2/93
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _STAB_H_
+#define _STAB_H_
+
+/*
+ * The following are symbols used by various debuggers and by the Pascal
+ * compiler.  Each of them must have one (or more) of the bits defined by
+ * the N_STAB mask set.
+ */
+
+#define	N_GSYM		0x20	/* global symbol */
+#define	N_FNAME		0x22	/* F77 function name */
+#define	N_FUN		0x24	/* procedure name */
+#define	N_STSYM		0x26	/* data segment variable */
+#define	N_LCSYM		0x28	/* bss segment variable */
+#define	N_MAIN		0x2a	/* main function name */
+#define	N_PC		0x30	/* global Pascal symbol */
+#define	N_RSYM		0x40	/* register variable */
+#define	N_SLINE		0x44	/* text segment line number */
+#define	N_DSLINE	0x46	/* data segment line number */
+#define	N_BSLINE	0x48	/* bss segment line number */
+#define	N_SSYM		0x60	/* structure/union element */
+#define	N_SO		0x64	/* main source file name */
+#define	N_LSYM		0x80	/* stack variable */
+#define	N_BINCL		0x82	/* include file beginning */
+#define	N_SOL		0x84	/* included source file name */
+#define	N_PSYM		0xa0	/* parameter variable */
+#define	N_EINCL		0xa2	/* include file end */
+#define	N_ENTRY		0xa4	/* alternate entry point */
+#define	N_LBRAC		0xc0	/* left bracket */
+#define	N_EXCL		0xc2	/* deleted include file */
+#define	N_RBRAC		0xe0	/* right bracket */
+#define	N_BCOMM		0xe2	/* begin common */
+#define	N_ECOMM		0xe4	/* end common */
+#define	N_ECOML		0xe8	/* end common (local name) */
+#define	N_LENG		0xfe	/* length of preceding entry */
+
+#endif
diff -r 06549f98901b toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h
--- a/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h	Fri Aug 02 14:36:52 2013 +0000
+++ b/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h	Fri Aug 02 14:42:20 2013 +0000
@@ -2813,7 +2813,7 @@
     LSS_INLINE _syscall6(void*, mmap,              void*, s,
                          size_t,                   l, int,               p,
                          int,                      f, int,               d,
-                         __off64_t,                o)
+                         off_t,                o)
 
     LSS_INLINE _syscall4(int, newfstatat,         int,   d,
                          const char *,            p,
diff -r 06549f98901b toolkit/mozapps/update/common/updatedefines.h
--- a/toolkit/mozapps/update/common/updatedefines.h	Fri Aug 02 14:36:52 2013 +0000
+++ b/toolkit/mozapps/update/common/updatedefines.h	Fri Aug 02 14:42:20 2013 +0000
@@ -106,8 +106,10 @@
 #ifdef SOLARIS
 # include <sys/stat.h>
 #else
+#if !defined(__linux__) || defined(__GLIBC__)
 # include <fts.h>
 #endif
+#endif
 # include <dirent.h>
 
 #ifdef XP_MACOSX
diff -r 06549f98901b toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/mozapps/update/updater/updater.cpp	Fri Aug 02 14:36:52 2013 +0000
+++ b/toolkit/mozapps/update/updater/updater.cpp	Fri Aug 02 14:42:20 2013 +0000
@@ -3369,6 +3369,7 @@
 int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
 {
   int rv = OK;
+#if !defined(__linux__) || defined(__GLIBC__)
   FTS *ftsdir;
   FTSENT *ftsdirEntry;
   NS_tchar searchpath[MAXPATHLEN];
@@ -3471,6 +3472,7 @@
   }
 
   fts_close(ftsdir);
+#endif
 
   return rv;
 }
diff -r 06549f98901b toolkit/xre/nsSigHandlers.cpp
--- a/toolkit/xre/nsSigHandlers.cpp	Fri Aug 02 14:36:52 2013 +0000
+++ b/toolkit/xre/nsSigHandlers.cpp	Fri Aug 02 14:42:20 2013 +0000
@@ -15,6 +15,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys/types.h>
 #include "prthread.h"
 #include "plstr.h"
 #include "prenv.h"
@@ -152,7 +153,7 @@
   status->__invalid = status->__denorm = status->__zdiv = status->__ovrfl = status->__undfl =
     status->__precis = status->__stkflt = status->__errsumm = 0;
 
-  __uint32_t *mxcsr = &uc->uc_mcontext->__fs.__fpu_mxcsr;
+  u_int32_t *mxcsr = &uc->uc_mcontext->__fs.__fpu_mxcsr;
   *mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
   *mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
 #endif
@@ -172,13 +173,13 @@
   *sw &= ~FPU_STATUS_FLAGS;
 #endif
 #if defined(__amd64__)
-  __uint16_t *cw = &uc->uc_mcontext.fpregs->cwd;
+  u_int16_t *cw = &uc->uc_mcontext.fpregs->cwd;
   *cw |= FPU_EXCEPTION_MASK;
 
-  __uint16_t *sw = &uc->uc_mcontext.fpregs->swd;
+  u_int16_t *sw = &uc->uc_mcontext.fpregs->swd;
   *sw &= ~FPU_STATUS_FLAGS;
 
-  __uint32_t *mxcsr = &uc->uc_mcontext.fpregs->mxcsr;
+  u_int32_t *mxcsr = &uc->uc_mcontext.fpregs->mxcsr;
   *mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
   *mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
 #endif
@@ -187,24 +188,24 @@
   ucontext_t *uc = (ucontext_t *)context;
 
 #if defined(__i386)
-  uint32_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[0];
+  u_int32_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[0];
   *cw |= FPU_EXCEPTION_MASK;
 
-  uint32_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[1];
+  u_int32_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[1];
   *sw &= ~FPU_STATUS_FLAGS;
 
   /* address of the instruction that caused the exception */
-  uint32_t *ip = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[3];
+  u_int32_t *ip = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[3];
   uc->uc_mcontext.gregs[REG_PC] = *ip;
 #endif
 #if defined(__amd64__)
-  uint16_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.cw;
+  u_int16_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.cw;
   *cw |= FPU_EXCEPTION_MASK;
 
-  uint16_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.sw;
+  u_int16_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.sw;
   *sw &= ~FPU_STATUS_FLAGS;
 
-  uint32_t *mxcsr = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.mxcsr;
+  u_int32_t *mxcsr = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.mxcsr;
   *mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
   *mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
 #endif
diff -r 06549f98901b tools/profiler/platform-linux.cc
--- a/tools/profiler/platform-linux.cc	Fri Aug 02 14:36:52 2013 +0000
+++ b/tools/profiler/platform-linux.cc	Fri Aug 02 14:42:20 2013 +0000
@@ -66,7 +66,7 @@
 
 #define SIGNAL_SAVE_PROFILE SIGUSR2
 
-#if defined(__GLIBC__)
+#if 1
 // glibc doesn't implement gettid(2).
 #include <sys/syscall.h>
 pid_t gettid()
diff -r 06549f98901b tools/profiler/shared-libraries-linux.cc
--- a/tools/profiler/shared-libraries-linux.cc	Fri Aug 02 14:36:52 2013 +0000
+++ b/tools/profiler/shared-libraries-linux.cc	Fri Aug 02 14:42:20 2013 +0000
@@ -35,7 +35,9 @@
 #ifdef ANDROID
 #include "ElfLoader.h" // dl_phdr_info
 #else
+extern "C" { // [Gregor] musl bug
 #include <link.h> // dl_phdr_info
+}
 #endif
 #include <features.h>
 #include <dlfcn.h>
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -199,7 +199,7 @@
 endif
 
 
-ifdef MOZ_ALSA
+ifdef MOZ_ALSA_LIBS
 EXTRA_DSO_LDOPTS += $(MOZ_ALSA_LIBS)
 endif
 
